home *** CD-ROM | disk | FTP | other *** search
/ 3D GFX / 3D GFX.iso / amiutils / i_l / irit5 / cagd_lib / cagd_err.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-31  |  5.7 KB  |  103 lines

  1. /******************************************************************************
  2. * Cagd_err.c - handler for all cagd library fatal errors.              *
  3. *******************************************************************************
  4. * Written by Gershon Elber, May. 91.                          *
  5. ******************************************************************************/
  6.  
  7. #include "cagd_loc.h"
  8.  
  9. typedef struct CagdErrorStruct {
  10.     CagdFatalErrorType ErrorNum;
  11.     char *ErrorDesc;
  12. } CagdErrorStruct;
  13.  
  14. static CagdErrorStruct ErrMsgs[] =
  15. {
  16.     { CAGD_ERR_180_ARC,            "Attempt to construct a 180 degrees arc" },
  17.     { CAGD_ERR_AFD_NO_SUPPORT,        "No support for such AFD operation." },
  18.     { CAGD_ERR_ALLOC_ERR,        "Memory allocation error" },
  19.     { CAGD_ERR_BSPLINE_NO_SUPPORT,    "Bspline basis type is not supported" },
  20.     { CAGD_ERR_BZR_CRV_EXPECT,        "Bezier curve is expected" },
  21.     { CAGD_ERR_BZR_SRF_EXPECT,        "Bezier surface is expected" },
  22.     { CAGD_ERR_BSP_CRV_EXPECT,        "Bspline curve is expected" },
  23.     { CAGD_ERR_BSP_SRF_EXPECT,        "Bspline surface is expected" },
  24.     { CAGD_ERR_CRV_FAIL_CMPT,        "Cannot make curves compatible" },
  25.     { CAGD_ERR_CRVS_INCOMPATIBLE,    "Curves for requested operation are incompatible" },
  26.     { CAGD_ERR_CUBIC_EXPECTED,        "Cubic polynomial expected." },
  27.     { CAGD_ERR_DEGEN_ALPHA,        "Degenerated Alpha matrix" },
  28.     { CAGD_ERR_DIR_NOT_CONST_UV,    "Dir is not one of CONST_U/V_DIR" },
  29.     { CAGD_ERR_DIR_NOT_VALID,        "Dir is not valid" },
  30.     { CAGD_ERR_INDEX_NOT_IN_MESH,    "Index is out of mesh range" },
  31.     { CAGD_ERR_KNOT_NOT_ORDERED,    "Provided knots are not in ascending order" },
  32.     { CAGD_ERR_LIN_NO_SUPPORT,        "Order below linear is not supported" },
  33.     { CAGD_ERR_NO_CROSS_PROD,        "No cross product for scalar surface" },
  34.     { CAGD_ERR_NOT_ENOUGH_MEM,        "Not enough memory, exit" },
  35.     { CAGD_ERR_NOT_IMPLEMENTED,        "Not implemented" },
  36.     { CAGD_ERR_NUM_KNOT_MISMATCH,    "Number of knots does not match" },
  37.     { CAGD_ERR_OUT_OF_RANGE,        "Data is out of range." },
  38.     { CAGD_ERR_PARSER_STACK_OV,        "Parser Internal stack overflow.." },
  39.     { CAGD_ERR_POWER_NO_SUPPORT,    "Power basis type is not supported" },
  40.     { CAGD_ERR_PT_OR_LEN_MISMATCH,    "PtType or Length mismatch" },
  41.     { CAGD_ERR_POLYNOMIAL_EXPECTED,    "Polynomial Crv/Srf expected." },
  42.     { CAGD_ERR_RATIONAL_EXPECTED,    "Rational Crv/Srf expected." },
  43.     { CAGD_ERR_SCALAR_EXPECTED,        "Scalar entity expected" },
  44.     { CAGD_ERR_SRF_FAIL_CMPT,        "Cannot make surfaces compatible" },
  45.     { CAGD_ERR_SRFS_INCOMPATIBLE,    "Surfaces for requested operation are incompatible" },
  46.     { CAGD_ERR_UNDEF_CRV,        "Undefined curve type" },
  47.     { CAGD_ERR_UNDEF_SRF,        "Undefined surface type" },
  48.     { CAGD_ERR_UNDEF_GEOM,        "Undefined geometry type" },
  49.     { CAGD_ERR_UNSUPPORT_PT,        "Unsupported point type" },
  50.     { CAGD_ERR_T_NOT_IN_CRV,        "Given t is not in curve's parametric domain" },
  51.     { CAGD_ERR_U_NOT_IN_SRF,        "Given u is not in u surface's parametric domain" },
  52.     { CAGD_ERR_V_NOT_IN_SRF,        "Given v is not in v surface's parametric domain" },
  53.     { CAGD_ERR_WRONG_DOMAIN,        "Given parameter is not in domain" },
  54.     { CAGD_ERR_W_NOT_SAME,        "Weights are not identical" },
  55.     { CAGD_ERR_WRONG_CRV,        "Provided curve type is wrong" },
  56.     { CAGD_ERR_WRONG_INDEX,        "Provided index is wrong" },
  57.     { CAGD_ERR_WRONG_ORDER,        "Provided order is wrong" },
  58.     { CAGD_ERR_WRONG_SRF,        "Provided surface type is wrong" },
  59.     { CAGD_ERR_WRONG_PT_TYPE,        "Provided point type is wrong" },
  60.     { CAGD_ERR_CANNOT_COMP_VEC_FIELD,    "Cannot compute vec field/normal" },
  61.     { CAGD_ERR_CANNOT_COMP_NORMAL,    "Cannot compute normal" },
  62.     { CAGD_ERR_REPARAM_NOT_MONOTONE,    "Reparametrization is not monotone" },
  63.     { CAGD_ERR_RATIONAL_NO_SUPPORT,    "Rational function is not supported" },
  64.     { CAGD_ERR_NO_SOLUTION,        "No solution" },
  65.     { CAGD_ERR_TOO_COMPLEX,        "Too complex" },
  66.     { CAGD_ERR_REF_LESS_ORIG,        "Refined object smaller than original" },
  67.     { CAGD_ERR_ONLY_2D_OR_3D,        "Only two or three dimensions are supported" },
  68.     { CAGD_ERR_DOMAIN_TOO_SMALL,    "Parametric domain is too small" },
  69.     { CAGD_ERR_PERIODIC_EXPECTED,    "Periodic geometry expected" },
  70.     { CAGD_ERR_PERIODIC_NO_SUPPORT,    "Periodic geometry is not supported" },
  71.     { CAGD_ERR_OPEN_EC_EXPECTED,    "Open end conditions expected" },
  72.  
  73.     { CAGD_ERR_UNDEFINE_ERR,        NULL }
  74. };
  75.  
  76. /*****************************************************************************
  77. * DESCRIPTION:                                                               M
  78. * Returns a string describing a the given error. Errors can be raised by     M
  79. * any member of this cagd library as well as other users. Raised error will  M
  80. * cause an invokation of CagdFatalError function which decides how to handle M
  81. * this error. CagdFatalError can for example, invoke this routine with the   M
  82. * error type, print the appropriate message and quit the program.            M
  83. *                                                                            *
  84. * PARAMETERS:                                                                M
  85. *   ErrorNum:   Type of the error that was raised.                           M
  86. *                                                                            *
  87. * RETURN VALUE:                                                              M
  88. *   char *:     A string describing the error type.                          M
  89. *                                                                            *
  90. * KEYWORDS:                                                                  M
  91. *   CagdDescribeError, error handling                                        M
  92. *****************************************************************************/
  93. char *CagdDescribeError(CagdFatalErrorType ErrorNum)
  94. {
  95.     int i = 0;
  96.  
  97.     for ( ; ErrMsgs[i].ErrorDesc != NULL; i++)
  98.     if (ErrorNum == ErrMsgs[i].ErrorNum)
  99.         return ErrMsgs[i].ErrorDesc;
  100.  
  101.     return "Undefined error";
  102. }
  103.